package com.facemox.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import com.facemox.bean.Module;
import com.facemox.bean.PermissionAuthentication;
import com.facemox.bean.Project;

public interface ModuleMapper {
    
    // 插入一条数据
    @Insert("INSERT INTO face_module(module_name,module_remark,project_id) values(#{moduleName},#{moduleRemark},#{projectId})")
    // 1、获取数据库自增ID，keyProperty：java对象的属性，keyColumn：数据库字段名称
    @Options(useGeneratedKeys=true,keyProperty="moduleId",keyColumn="module_id")
    int insertModule(Module module);
    
    // 插入一条数据
    @Insert("INSERT INTO face_project(project_name,project_remark) values(#{projectName},#{projectRemark})")
    // 1、获取数据库自增ID，keyProperty：java对象的属性，keyColumn：数据库字段名称
    @Options(useGeneratedKeys=true,keyProperty="projectId",keyColumn="project_id")
    int insertProject(Project project);
    
    // 1、查找全部项目
    @Select("select * from face_project")
    @Results({
        @Result(column = "project_id",property = "projectId"),
        @Result(column = "project_name",property = "projectName"),
        @Result(column = "project_remark",property = "projectRemark")
    })
    List<Project> getAllProject();
    
    // 2、查找全部模块
    @Select("select * from face_module")
    @Results({
        @Result(column = "module_id",property = "moduleId"),
        @Result(column = "module_name",property = "moduleName"),
        @Result(column = "module_remark",property = "moduleRemark"),
        @Result(column = "project_id",property = "projectId")
    })
    List<Module> getAllModule();
    
    // 2、查找全部权限
    @Select("select * from face_authentication")
    @Results({
        @Result(column = "authentication_id",property = "authenticationId"),
        @Result(column = "authentication_type",property = "authenticationType"),
        @Result(column = "authentication_name",property = "authorizationName"),
        @Result(column = "username",property = "username"),
        @Result(column = "password",property = "password"),
        @Result(column = "token",property = "token"),
        @Result(column = "remark",property = "remark")
    })
    List<PermissionAuthentication> getAllAuthorization();
}
